#include "TextField.h"


TextField::TextField(void)
{
	_loc = vector3( 100, 100, 0);
	_color = WHITE;
	_line1 = "";
	_line2 = "";
}

TextField::TextField( vector3 loc, vector3 color, char * text, char * line2 = "" )
{
	_loc = loc;
	_color = color;
	_line1 = text;
	_line2 = line2;
}

TextField::~TextField(void)
{
}

void TextField::setText( char * newStr, char * line2NewStr = "`~`"){
	_line1 = newStr;
	if( line2NewStr != "`~`" ){
		_line2 = line2NewStr;
	}
}

void TextField::clearText()
{
	_line1 = "";
	_line2 = "";
}

void TextField::Render()
{
	DrawTools::drawText( _loc, _line1, _color );
	DrawTools::drawText( vector3( _loc.getX(), _loc.getY()- NEW_LINE_DIST, _loc.getZ() ), _line2, _color );
}

char* TextField::numberToLine( int number )
{
	char * line = "";
	stringstream ss;
	ss << number;
	string s = "          " + ss.str();
	line=new char[s.size()+1];
	line[s.size()]=0;
	memcpy(line,s.c_str(),s.size());
	return line;
}